<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <!--<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">-->
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>星趣米娱管理后台</title>
    <link rel="stylesheet" href="__STATIC__/layui/dist/css/layui.css">
    <link rel="stylesheet" href="__STATIC__/css/my.css">
    <link rel="stylesheet" class="theme" type="text/css">
    <style>
    </style>
    {block name="css"}{/block}
</head>
<body>
<!--<div id="miyuMark" style="width: 100%; height: 100%; "><img style="position:absolute; top:50%; left: 50%; margin-left:-75px; margin-top:-75px;" src="/static/img/miyu.gif" /></div>-->
<div class="layui-layer layui-layer-loading" id="layui-loading" type="loading" times="1" showtime="0" contype="string" style="z-index: 19891015; top: 48%; left: 48%;"><div id="" class="layui-layer-content layui-layer-loading"></div><span class="layui-layer-setwin"></span></div>
{block name="content"}{/block}
<script src="__STATIC__/layui/dist/layui.js"></script>
<script>
    layui.config({
        base: '__STATIC__/js/model/' //设定扩展的Layui模块的所在目录，一般用于外部模块扩展
        ,version: true //一般用于更新模块缓存，默认不开启。设为true即让浏览器不缓存。也可以设为一个固定的值，如：201610
        ,debug: true //用于开启调试模式，默认false，如果设为true，则JS模块的节点会保留在页面
    }).extend({
        demo: 'demo' //如果test.js是在根目录，也可以不用设定别名
        ,common: 'common'
    });

    //主框架js
    layui.use(['element', 'layer', 'form', 'layer'], function(){
        var $ = layui.$
            ,element = layui.element
            ,form = layui.form
            ,layer = layui.layer;

        //右键事件
        $("body").bind("contextmenu", function(){
            return false;
        });
        $("body").mousedown(function(e) {
            if(3 == e.which) {
                if($('#rightBox').length==0){
                    $(this).append($('<div id="rightBox"><a href="javascript:;" id="refresh"><i class="layui-icon">&#x1002;</i> 刷新当前标签</a><a href="javascript:;" id="closeNow"><i class="layui-icon">&#x1006;</i> 关闭当前标签</a><a href="javascript:;" id="closeAll"><i class="layui-icon">&#x1006;</i> 关闭所有标签</a></div>'));
                }
                $('#rightBox').css({'top':e.pageY+'px', 'left':e.pageX+'px'});
            }
        }).bind('body click', function() {
            $('#rightBox').remove();
        })

        $("body").on('click', '#refresh', function(){
            window.location.reload();
        })
        $("body").on('click', '#closeNow', function(){
            if($('.my-tab .my-tab-title li', window.parent.document).length == 2){
                $('.my-iframe:first', window.parent.document)[0].contentWindow.openTime();
            }

            var index = $('.my-tab .my-tab-title .layui-this', window.parent.document).index(); //2
            var len = $('.my-tab .my-tab-title li', window.parent.document).length; //2

            if(len == 2){
                $('.my-tab .my-tab-title li:eq(0)', window.parent.document).addClass('layui-this');
                $('.my-tab .my-tab-content>div:eq(0)', window.parent.document).addClass('layui-show');
                $('.my-tab .my-tab-title li:eq('+index+')', window.parent.document).remove();
                $('.my-tab .my-tab-content>div:eq('+index+')', window.parent.document).remove();
            }else if(len>2){
                if((index+1)==len){
                    $('.my-tab .my-tab-title li:eq('+(index-1)+')', window.parent.document).addClass('layui-this');
                    $('.my-tab .my-tab-content>div:eq('+(index-1)+')', window.parent.document).addClass('layui-show');
                    $('.my-tab .my-tab-title li:eq('+(index)+')', window.parent.document).remove();
                    $('.my-tab .my-tab-content>div:eq('+(index)+')', window.parent.document).remove();
                }else{
                    $('.my-tab .my-tab-title li:eq('+(index+1)+')', window.parent.document).addClass('layui-this');
                    $('.my-tab .my-tab-content>div:eq('+(index+1)+')', window.parent.document).addClass('layui-show');
                    $('.my-tab .my-tab-title li:eq('+(index)+')', window.parent.document).remove();
                    $('.my-tab .my-tab-content>div:eq('+(index)+')', window.parent.document).remove();
                }
            }
        })
        $("body").on('click', '#closeAll', function(){
            var index = $('.my-tab .layui-this', window.parent.document).index(); //1
            var len = $('.my-tab .my-tab-title li', window.parent.document).length; //3

            for (var i=len; i>=0; i--){
                if(i==0){
                    continue;
                }
                if(i!=index){
                    $('.my-tab .my-tab-title li:eq('+i+')', window.parent.document).remove();
                    $('.my-tab .my-tab-content>div:eq('+i+')', window.parent.document).remove();
                }
            }
        })

        //主题
        if(layui.data('theme').href != undefined){
            $(".theme").attr("href", layui.data('theme').href);
        }else{
            $(".theme").attr("href", "__STATIC__/css/cyan.css");
        }

        $(document).keyup(function(event){
            if(event.keyCode == 13){
                $("#searchBox .searchBtn").trigger("click");
                $("#searchBox .searchBtn").css({opacity:'0.8'});
            }
        });

        $("#searchBox .searchBtn").hover(function(){
            $("#searchBox .searchBtn").css({opacity:'0.8'});
        }, function(){
            $("#searchBox .searchBtn").css({opacity:'1'});
        })

        //5秒后loading还存在，提示刷新
//        setTimeout(function(){
//            if( $('#layui-loading').is(":visible") ){
//                layer.confirm('网络连接已经超过10秒，是否重新刷新?', {btn: ['刷新', '关闭'],offset: '250px', icon: 3, title:'提示'}, function(index){
//                    window.location.reload();
//                    layer.close(index);
//                });
//            }
//        },5000)


    });
</script>
{block name="js"}{/block}
</body>
</html>